package com.app.view_controller.custom_view;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.TextView;

public class TextViewWithFont extends TextView {

	@SuppressWarnings("unused")
	private static final boolean DEBUG = true;
	private static final String TAG = "ROBOTO_TEXT_VIEW";

	public TextViewWithFont(Context context) {
		super(context);
	}

	public TextViewWithFont(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context, attrs);
	}

	public TextViewWithFont(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		init(context, attrs);
	}

	private void init(Context context, AttributeSet attrs) {
		for (int i = 0; i < attrs.getAttributeCount(); i++) {

			String ttfName = attrs
					.getAttributeValue("http://schemas.android.com/apk/res/com.app.alarm", "textViewFont");
			if (ttfName != null)
				try {
					Typeface font = Typeface.createFromAsset(context.getAssets(), "fonts/" + ttfName);
					setTypeface(font);
				} catch (Exception e) {
					Log.e(TAG, "Error loading ttf font. 404 File Not Found.");
				}

		}

	}

}
